<?php
    class Guest{
       protected $user_level='';
       protected $user_access=array();
       public function __construct() {
          $this->setUser_level('guest');
          $this->set_allow(array('home'));
       }
       
       public function getUser_access() {
           return $this->user_access;
       }
  
       public function getUser_level() {
           return $this->user_level;
       }

       public function setUser_level($user_level) {
           $this->user_level = $user_level;
       }
      
       public function setParent_role_object($parent_object) {
           foreach ($parent_object->getUser_access() as $val) {
               if(!in_array($val,$this->user_access))
                 $this->user_access[] = $val;
           }
       }
       
              
       /*
        * access is format
        * 'news|contact'
        */
       public function set_allow($access){
           if(is_array($access)){
               foreach ($access as $value) {
                   if(!in_array($value,$this->user_access))
                    $this->user_access[] = $value;
               }
           }else {
               if(!in_array($access,$this->user_access))
                 $this->user_access[] = $access;
           }
       }
       
       public function set_deny($access){
           if(is_array($access)){
               foreach ($this->user_access as $key => $value) {
                   foreach ($access as $val) {
                       if($value==$val){
                           unset($this->user_access[$key]);
                       }
                   }
               }
           }else {
              foreach ($this->user_access as $key => $value) {
                  if($value==$access){
                      unset($this->user_access[$key]);
                  }
              }
           }
       }
       
       
   
   } 
?>
